// components/header/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: String,
    icon: String,
    bgColor: {
      type: String,
      value: '#ffffff'
    },
    borderBottom: {
      type: String,
      value: '1rpx #efefef solid'
    },
    showBack: {
      type: Boolean,
      value: true
    },
    customBack: {
      type: Boolean,
      value: false,
    }
  },
  /**
   * 组件的初始数据
   */
  data: {

  },
  ready() {
    console.log('header ready');
  },
  /**
   * 组件的方法列表
   */
  methods: {
    handleBack() {
      var pages = getCurrentPages();
      if (this.data.customBack) {
        this.triggerEvent('back');
      } else {
        if (pages.length > 1) {
          wx.navigateBack({})
        } else {
          wx.navigateTo({
            url: '/pages/index/index',
          })
        }
      }
    }
  }
})